package top.laoliu.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import top.laoliu.pojo.ResumeVo;
import top.laoliu.service.ResumeService;

/**
 * @Author: acer
 * @Date: 2020/10/18 14:15
 * @Description:
 */
@Controller
@RequestMapping("/resume")
public class ResumeController {
    @Autowired
    private ResumeService resumeService;

    @RequestMapping("/saveResumeData")
    @ResponseBody
    public String saveResumeData(ResumeVo resumeVo) {
        System.out.println(resumeVo);
        ResumeVo resumeVoByUserId = resumeService.getResumeVoByUserId(resumeVo.getUser_id());

        if (resumeVoByUserId==null){
            boolean isInsertSuccess = resumeService.insertResume(resumeVo);
            if (isInsertSuccess){
                return "修改成功";
            }
        }else {
            resumeVo.setEdu_id(resumeVoByUserId.getEdu_id());
            resumeVo.setExperience_id(resumeVoByUserId.getExperience_id());
            resumeVo.setProject_id(resumeVoByUserId.getProject_id());
            resumeVo.setSkill_id(resumeVoByUserId.getSkill_id());
            boolean isUpdateSuccess = resumeService.updateResume(resumeVo);
            if (isUpdateSuccess){
                return "修改成功";
            }
        }
        return "修改失败";
    }
}
